package vip.liux.front.adapter.controller;

import io.github.resilience4j.ratelimiter.annotation.RateLimiter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.liux.front.application.clients.OpenApiFeignClient;

import java.util.List;

import static vip.liux.front.application.clients.OpenApiFeignClient.*;

@RestController
@RequestMapping("/api/open-api")
public class OpenApiController {
    private static final Logger log = LoggerFactory.getLogger(OpenApiController.class);
    final OpenApiFeignClient openApiFeignClient;

    public OpenApiController(OpenApiFeignClient openApiFeignClient) {
        this.openApiFeignClient = openApiFeignClient;
    }

    @GetMapping("/bilibili")
    @RateLimiter(name = "default")
    public List<BilibiliDto> bilibili() {
        ResponseData<BilibiliDto> response = openApiFeignClient.bilibili();
        return response.getData();
    }
}
